/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2005
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.model.disc.element;

import java.util.ArrayList;
import java.util.ListIterator;

import br.ufmg.dees.insane.model.disc.integrationpoint.IntegrationPoint;
import br.ufmg.dees.insane.model.disc.integrationpoint.VolumeGaussPoint;
import br.ufmg.dees.insane.model.disc.node.Node;
import br.ufmg.dees.insane.model.disc.parametricintegration.ParametricIntegration;
import br.ufmg.dees.insane.util.IMatrix;
import br.ufmg.dees.insane.util.IPoint3d;

/**
*A class representing a tetrahedral parametric element.<p>
*
*@author Lucas, Marcelo & Pitangueira, Roque
*@version 1.0
*@since June 2004
*/

public abstract class Tetrahedral extends ParametricElement
{
	/** Return the ParametricIntegration object related to the line loads for this Tetrahedral ParametricElement
	*@return  The ParametricIntegration object related to the line loads for this Tetrahedral ParametricElement.
	*/
	public abstract ParametricIntegration getLineEqLoad();
	
	/** Return the ParametricIntegration object related to the volume loads for this Tetrahedral ParametricElement
	*@return  The ParametricIntegration object related to the volume loads for this Tetrahedral ParametricElement.
	*/
	protected abstract ParametricIntegration getAreaEqLoad();
	
	/** Return the ParametricIntegration object related to the volume loads for this Element
	*@return  The ParametricIntegration object related to the volume loads for this Element.
	*/
	protected abstract ParametricIntegration getVolumeEqLoad();
	
	/** Return a ArrayList with PointForces representing the equivalent nodal load.
	*The utility of this method is receive the ParametricIntegration object and select its apropriated integration type method.
	*@return The ArrayList with PointForces representing the equivalent nodal load.
	*/
	protected abstract ArrayList getIntegralValues(ParametricIntegration a);
	
//********************************************************************************	
	
	/** Generates Gauss Points and theirs Weights factors of this Tetrahedral ParametricElement. 
	*/
	public void generateIntegrationPoints()
	{
		int k = 1;
		for(int i = 0; i < (myIntegrationOrder.getXiIntegOrder()); i++)
		{
			IntegrationPoint ip = new VolumeGaussPoint();
			ip.setCoord1((myIntegrationOrder.getXiIntegOrder()-1),(4*i));
			ip.setCoord2((myIntegrationOrder.getXiIntegOrder()-1),(4*i+1));
			ip.setCoord3((myIntegrationOrder.getXiIntegOrder()-1),(4*i+2));
			ip.setWeight((myIntegrationOrder.getXiIntegOrder()-1),i);
			ip.setLabel("GP-"+(k));
			integrationPoints.add(ip);
			k++;
		}		
	}
	
//********************************************************************************
	
	/** Returns the nodal coordinates matrix of this Tetrahedral ParametricElement
	*@return The nodal coordinates matrix.
	*/
	protected IMatrix getNodesCoord()
	{
		Node node;
		IPoint3d nodeCoord;
		int nNos = incidence.size();
		IMatrix cN = new IMatrix(nNos,3);
		
		ListIterator nds = incidence.listIterator();
		int position = 0;
		while (nds.hasNext()) 
		{
			node = (Node) nds.next();
			nodeCoord = node.getCoord();
			
			cN.setElement((position),0,nodeCoord.x);
			cN.setElement((position),1,nodeCoord.y);
			cN.setElement((position),2,nodeCoord.z);
			
			position++;
		}
			return(cN);
	}
	
//********************************************************************************	
	
	/** Return the element integration coefficient.
	*@return 1/6.
	*/
	protected double getElmCoefficient() 
	{
		return (0.16666666666666667);
	}
	
//********************************************************************************	

	/** Return the inverse of jacobian matrix.
	*@param a The jacobian matrix.
	*@return the inverse of jacobian matrix.
	*/
/*	protected IMatrix invertJacobian(IMatrix a)
	{
		IMatrix b = new IMatrix(3,3);
		b.setZero();
		
		b.setElement(0,0, (((a.getElement(1,1))*(a.getElement(2,2)))-((a.getElement(1,2))*(a.getElement(2,1)))));
		b.setElement(0,1, (-1)*(((a.getElement(1,0))*(a.getElement(2,2)))-((a.getElement(1,2))*(a.getElement(2,0)))));
		b.setElement(0,2, (((a.getElement(1,0))*(a.getElement(2,1)))-((a.getElement(1,1))*(a.getElement(2,0)))));
		b.setElement(1,0, (-1)*(((a.getElement(0,1))*(a.getElement(2,2)))-((a.getElement(0,2))*(a.getElement(2,1)))));
		b.setElement(1,1, (((a.getElement(0,0))*(a.getElement(2,2)))-((a.getElement(0,2))*(a.getElement(2,0)))));
		b.setElement(1,2, (-1)*(((a.getElement(0,0))*(a.getElement(2,1)))-((a.getElement(0,1))*(a.getElement(2,0)))));
		b.setElement(2,0, (((a.getElement(0,1))*(a.getElement(1,2)))-((a.getElement(0,2))*(a.getElement(1,1)))));
		b.setElement(2,1, (-1)*(((a.getElement(0,0))*(a.getElement(1,2)))-((a.getElement(0,2))*(a.getElement(1,0)))));
		b.setElement(2,2, (((a.getElement(0,0))*(a.getElement(1,1)))-((a.getElement(0,1))*(a.getElement(1,0)))));
		
		b.transpose();
		b.setScale((1/(a.determinantLU())));
		
		return b;
	}
*/
//********************************************************************************

}
